﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestPasswordGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            int password_count = 0;
            int new_password_index = 0;
            
            int number_of_passwords = 622; // password_counts => Number of password
            Random randomizer = new Random();
            string allowed_characters = string.Empty;
            int password_length = 6;
            List<string> password_list = new List<string>();

            // CONFIGURE PASSWORD
            allowed_characters = allowed_characters + "1234567890";
            allowed_characters = allowed_characters + "abcdefghijklmnopqrstuvwxyz";
            //allowedCharacters = allowedCharacters + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            for (password_count = 0; password_count < number_of_passwords; password_count++)
            {
                int charIndex = 0;
                char[] new_password = new char[password_length];
                for (new_password_index = 0; new_password_index < password_length; new_password_index++)
                {
                    charIndex = randomizer.Next(0, allowed_characters.Length);
                    new_password[new_password_index] = allowed_characters[charIndex];
                }
                Console.WriteLine("Password: {0}", new string(new_password));
                password_list.Add(new string(new_password));
            }
            
            Console.WriteLine("[START]");

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\temp\\password_list.txt", true))
            {
                sw.AutoFlush = true;
                foreach (string pwd in password_list)
                {
                    sw.WriteLine(pwd);
                }
            }

            Console.WriteLine("[END]");
            Console.ReadLine();
        }
    }
}
